package com.zyl.util;
 

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.widget.TextView;
import android.widget.Toast;

public class Util {
	public static void showToast(final Activity activity,final String content) {
        activity.runOnUiThread(new Runnable() {
            
            @Override
            public void run() {
                Toast toast = Toast.makeText(activity, content, Toast.LENGTH_SHORT);
                toast.show();
                
            }
        });
       
    }
    public static void setTextViewContent(final Activity activity,final TextView textView,final String content) {
        activity.runOnUiThread(new Runnable() {
            
            @Override
            public void run() {
               if(textView!=null){
                   textView.setText(content);
               }
                
            }
        });
       
    }
    public static boolean isNetworkAvailable( Activity activity ) {
		final ConnectivityManager manager = (ConnectivityManager) activity.getSystemService(activity.CONNECTIVITY_SERVICE);
		// final NetworkInfo wifi =
		// manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);

		final NetworkInfo[] info = manager.getAllNetworkInfo();
		for (int i = 0; i < info.length; ++i) {
			if (info[i].isConnected()) {
				return true;
			}
		}

		return false;
	}
    
    public static void alert(Activity  activity ) {
    	 
			Dialog dialog = new AlertDialog.Builder(  activity ).setTitle("提示")
			.setMessage("是否需要写日志")
			.setPositiveButton("确定", new DialogInterface.OnClickListener() {
				public void onClick(DialogInterface dialog, int which) {
					 
				}
			}).setNegativeButton("取消", new DialogInterface.OnClickListener() {
				public void onClick(DialogInterface dialog, int which) {
					 
				}
			}).create();
			dialog.show();
		 ;
	}
}
